package main

import (
	"fmt"
)

// 日志
//func init() {
//	logFile, err := os.OpenFile("./log.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
//	if err != nil {
//		fmt.Println("打开日志文件失败, err:", err)
//		return
//	}
//	multiWriter := io.MultiWriter(os.Stdout, logFile)
//	log.SetOutput(multiWriter)
//}

func main() {
	//config.InitConf()  //初始化配置文件
	//models.InitMysql() //初始化数据库
	////路由
	//r := gin.Default()
	//routes.RegisterRoute(r)
	//err := r.Run(":5000")
	//if err != nil {
	//	fmt.Println("run fail >>", err.Error())
	//}
	//

	//var cat = interface_demo.Cat{Name: "maomi"}
	//cat.DoRun("cat run")
	//cat.DoCall("cat call")
	//
	//var animal interface_demo.AnnimalInterface
	//
	//animal = &cat
	//animal.DoCall("cat run")

	//mapDemo()

	pointer()
}

func mapDemo() {
	var m1 = map[string]string{}

	//m1 = make(map[string]string)

	m1["key1"] = "val1"
	m1["key2"] = "val2"
	fmt.Println("m1 ", m1)
	fmt.Println("------------------")

	m2 := make(map[string]string, 10)
	m2["key1"] = "val1"
	m2["key2"] = "val2"

	fmt.Println("m2 ", m2)
}

func sliceDemo() {
	var s1 []int
	s1 = make([]int, 10)
	s1[0] = 10
	s1 = append(s1, 19)
	s1 = append(s1, 10)
	fmt.Println(s1)
}

/**
* https://blog.csdn.net/qq_45070951/article/details/126052659
 */
func sliceAndMap() {
	var ms map[string][]int

	ms = make(map[string][]int, 10)
	ms["key1"] = []int{10}
	ms["key2"] = []int{11}
	fmt.Println(ms)

	fmt.Println("--------------")

	var sm []map[string]string
	sm = make([]map[string]string, 10)
	sm[0] = make(map[string]string)
	sm[0]["key1"] = "val1"
	sm[0]["key2"] = "val2"
	fmt.Println(sm)

}

func pointer() {
	var ipointer *int
	i := 10
	ipointer = &i

	var ipointer2 = new(int)
	ipointer2 = &i
	fmt.Println(*ipointer, i, *ipointer2)

}
